package com.tadpole.music.view.widget;

import android.app.Activity;
import android.view.View;
import android.view.animation.Animation;
import android.widget.TextView;

import com.tadpole.music.R;

import razerdp.basepopup.BasePopupWindow;

/**
 * 退出考试弹窗
 * Created By 孙岩
 * on 2020/10/9
 */
public class SingleOutPopup extends BasePopupWindow implements View.OnClickListener {
    private TextView tvCancel;
    private TextView tvLoginOut;
    private TextView tvText;
    private LoginOutPopup.IModeSelection iModeSelection;
    //1表示考试 2表示训练
    private int flag;
    public SingleOutPopup(Activity context,int flag) {
        super(context);
        tvCancel = (TextView) findViewById(R.id.tvCancel);
        tvLoginOut = (TextView) findViewById(R.id.tvLoginOut);
        tvText = (TextView) findViewById(R.id.tvText);
        tvCancel.setOnClickListener(this);
        tvLoginOut.setOnClickListener(this);
        if(flag==1){
            tvText.setText("是否退出考试\n退出后将会重新开始答题");
        }else if(flag==2){
            tvText.setText("是否退出训练\n退出后将会重新开始答题");
        }
    }


    @Override
    protected Animation initShowAnimation() {
        return null;
    }

    @Override
    public View getClickToDismissView() {
        return getPopupWindowView();
    }

    @Override
    public View onCreatePopupView() {
        return createPopupById(R.layout.pop_single_out);
    }

    @Override
    public View initAnimaView() {
        return findViewById(R.id.rlLoginOut);
    }

    public void setModeListener(LoginOutPopup.IModeSelection iModeSelection) {
        this.iModeSelection = iModeSelection;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.tvLoginOut:
                iModeSelection.getMode(1);
                break;
            case R.id.tvCancel:
                iModeSelection.getMode(2);
                break;
        }
    }

    public interface IModeSelection{
        void getMode(int mode);
    }
}
